package com.dps.omc.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dps.omc.model.User;
import com.dps.omc.service.IJobReportDateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
public class HomeAction extends BaseAction{

    @Autowired
    private IJobReportDateService jobReportDateService;

    @RequestMapping(value="/installok")
    @ResponseBody
    public String installOk(ModelMap model,HttpServletRequest request,HttpServletResponse response){
        return "succ";
    }    

    @RequestMapping(value="/")
    public String home(ModelMap model,HttpServletRequest request,HttpServletResponse response){
//        return "redirect:/index.html";
        User user = getCurrentUser();
        model.addAttribute("realName", user.getRealName());
        return "index";
    }

    @RequestMapping(value="/index")
    public String renderMainView(ModelMap model,HttpServletRequest request,HttpServletResponse response){
        User user = getCurrentUser();
        model.addAttribute("username", user.getRealName());
        return "index";
    }

//    @RequestMapping(value="/board")
//    public String board(ModelMap model,HttpServletRequest request,HttpServletResponse response){
//
//        User user = getCurrentUser();
//        model.addAttribute("username", user.getRealName());
//        return "board";
//    }

    @RequestMapping(value="/board")
    public String board(ModelMap model,HttpServletRequest request,HttpServletResponse response){

//        User user = getCurrentUser();
//        model.addAttribute("username", user.getRealName());
//        return "redirect:/admin/jobreportdate/query";
        return "board";
    }


    @RequestMapping(value="/terminal")
    public String termimal(ModelMap model,HttpServletRequest request,HttpServletResponse response){

        return "terminal";
    }

//    @RequestMapping(value="/socket.io/1")
//    @ResponseBody
//    public String socket(ModelMap model,HttpServletRequest request,HttpServletResponse response){
//
//        return "test";
//    }



    //reportDate
    //jobSucc
    //jobFail
//    private List<Map<String,Object>>  getData() throws ParseException {
//        List<Map<String,Object>> data = new ArrayList<>();
//        Map map1 = new HashMap();
//        Map map2 = new HashMap();
//        map1.put("reportDate", DateUtils.parseDate("2016-05-15"));
//        map1.put("jobSucc",10);
//        map1.put("jobFail",5);
//
//        map2.put("reportDate", DateUtils.parseDate("2016-05-16"));
//        map2.put("jobSucc",15);
//        map2.put("jobFail",3);
//
//        data.add(map1);
//        data.add(map2);
//        return data;
//    }
}
